<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html lang="en">
  <head>
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta name="created" content="2018-10-23T06:18:10.521000000">
    <meta name="changed" content="2019-12-26T06:18:42.262000000">
    <meta http-equiv="content-type" content="text/html; charset=utf-8">
    <meta http-equiv="Content-Language" content="en">
    <title>
      Debugging subcircuits
    </title>
    <link rel="stylesheet" type="text/css" href="../../style.css">
  </head>
  <body>
    <div class="maindiv">
      <h1>
        Debugging subcircuits
      </h1>
      <p>
        As you test larger circuits, you will likely find bugs. To nail down what's going wrong, exploring what's going on in the subcircuits while running the overall circuit can help. To enter the subcircuit's state, you can use any of three different techniques. 
	  <p>
	  </p>
		The most straightforward is probably to view the simulation hierarchy by by clicking on the <b class="button">&nbsp;Simulate&nbsp;</b> tab, or by selecting menu <b class=menu>|&nbsp;Project&nbsp;|</b>→<b class=menu>| View Simulation Tree&nbsp;|</b>. This switches the explorer pane so that it shows the hierarchy of subcircuits being simulated.
      </p>
      <p align="center">
        <img class="notscal" src="../../../../img-guide/subcirc-hierarchy.png" alt="#########">
      </p>
      <p>
        <b class="tkeybd">Double-clicking</b> an element in this hierarchy will display what is happening inside that subcircuit.
      </p>
      <p>
        The second way you can enter a subcircuit is to bring up its popup menu by <b class="tkeybd">right-clic</b> or <b class="tkeybd">Ctrl+Click</b> it, and then choosing the option <b class=menu>|&nbsp;View&nbsp;<i>"circuit_name"</i>&nbsp;|</b>.
      </p>
      <p align="center">
        <img src="../../../img-guide/subcirc-8-delve.png" alt="#########">
      </p>
      <p>
        And the third way is to first ensure the Poke Tool (<img class="icontxt" src="../../../../icons/1616/toolpoke.png" alt="#########">) is selected and then <b class="tkeybd">click</b> the subcircuit you want to enter; a magnifying glass will appear over the subcircuit's center, and <b class="tkeybd">double-clicking</b> the magnifying glass will enter the subcircuit's state.
      </p>
      <p align="center">
        <img class="notscal" src="../../../../img-guide/subcirc-delve.png" alt="#########">
      </p>
      <p>
        In any case, once you enter the subcircuit, you'll see that the pins' values in the subcircuit match the values being sent through them from the containing circuit.
      </p>
      <p align="center">
        <img src="../../../../img-guide/subcirc-delve2.png" alt="#########">
      </p>
      <p>
        While in the subcircuit, you are allowed to alter the circuit. If the changes affect any of the subcircuit's outputs, they are propagated into the containing circuit. One exception: The subcircuit inputs are determined based on the values coming into the circuit from the supercircuit, so it doesn't make sense to toggle those values. If you attempt to poke a subcircuit's input, a dialog will pop up asking, <b class=refquest>The pin is tied to the supercircuit state. Create a new circuit state?</b> Clicking No will cancel the toggle request, while clicking Yes will create a copy of the viewed state, divorced from the outer circuit, with the input pin toggled.
      </p>
      <p>
        Once you have completed viewing and/or editing, you can return to the parent circuit either by double-clicking the parent circuit in the explorer pane, or via the menu <b class=menu>|&nbsp;Simulate&nbsp;|</b>→ <b class=menu>|&nbsp;Go Out To State&nbsp;<i>"circuit_name"</i>&nbsp;|</b>.
      </p>
      <p>
        <b>Next:</b> <a href="sub-library.html">Logisim libraries</a>.
      </p>
    </div>
  </body>
</html>
